Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimum length for responses to be gzipped #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ioppermann
Copy link

Very short responses become larger if they are gzipped. With
the minLength parameter you can define what minimum length a
response should have before it is gzipped. The response is
buffered up to the minimum length. As soon as the length of
the response becomes larger than the minimum length, the buffered
part will be written to the gzip writer and the headers will be
set accordingly. After that no more buffering will be applied.
If the response stays shorter than the minimum length, it will
stay uncompressed and no Accept-Encoding and Vary headers will
be set.

Very short responses become larger if they are gzipped. With
the minLength parameter you can define what minimum length a
response should have before it is gzipped. The response is
buffered up to the minimum length. As soon as the length of
the response becomes larger than the minimum length, the buffered
part will be written to the gzip writer and the headers will be
set accordingly. After that no more buffering will be applied.
If the response stays shorter than the minimum length, it will
stay uncompressed and no Accept-Encoding and Vary headers will
be set.
@codecov-io
Copy link

codecov-io commented Dec 5, 2018

Codecov Report

Merging #20 into master will decrease coverage by 0.24%.
The diff coverage is 93.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #20      +/-   ##
=======================================
- Coverage   90.24%   90%   -0.25%     
=======================================
  Files           1     1              
  Lines          41    60      +19     
=======================================
+ Hits           37    54      +17     
- Misses          3     4       +1     
- Partials        1     2       +1
Impacted Files Coverage Δ
gzip.go 90% <93.33%> (-0.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9117ce...cc8da47. Read the comment docs.

@@ -39,7 +39,7 @@ import (

func main() {
r := gin.Default()
r.Use(gzip.Gzip(gzip.DefaultCompression))
r.Use(gzip.Gzip(gzip.DefaultCompression, 0))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not part of the project but can you add this by using options pattern so it doesn't break all the existing code out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants